package com.chixing.day08_interface;

/*
* 把 A implements Comparable<T> 比较两个对象的先后顺序
* */
public class Product implements  Comparable<Product>{

    private String proName;
    private int proSale;
    private float priPrice;

    public Product(){}

    public Product(String proName, int proSale, float priPrice) {
        this.proName = proName;
        this.proSale = proSale;
        this.priPrice = priPrice;
    }

    public String getProName() {
        return proName;
    }

    public void setProName(String proName) {
        this.proName = proName;
    }

    public int getProSale() {
        return proSale;
    }

    public void setProSale(int proSale) {
        this.proSale = proSale;
    }

    public float getPriPrice() {
        return priPrice;
    }

    public void setPriPrice(float priPrice) {
        this.priPrice = priPrice;
    }


    @Override
    public int compareTo(Product anotherProduct) {
        if (this.proSale > anotherProduct.proSale)
            return 1;
        if ((this.proSale == anotherProduct.proSale) && (this.priPrice > anotherProduct.priPrice))
            return 1;
        if ((this.proSale == anotherProduct.proSale) && (this.priPrice == anotherProduct.priPrice))
            return 0;
        return -1;
    }


    /*@Override
    public int compareTo(Product anotherProduct) {
        if (this.proSale != anotherProduct.proSale)
            return this.proSale - anotherProduct.proSale;
        else  if (this.priPrice != anotherProduct.priPrice)
            return (int)(this.priPrice - anotherProduct.priPrice);
        if (this.proName.compareTo(anotherProduct.proName))

    }*/


}
